package core.database.model.basicPackage;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;

import core.database.MessageType;

@Entity
@Table(name = "messageReceived")
public class MessageReceived implements Serializable {
	private static final long serialVersionUID = -7017455107277140708L;
	@Id
	@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id = null;
	@Column(name = "type", nullable = false)
	private MessageType type;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created", nullable = false)
	private Date created;
	@Type(type = "text")
	private String value;
	@Column(name = "isHandled")
	private Boolean isHandled = false;

	public Long getId() {
		return id;
	}

	@SuppressWarnings("unused")
	private void setId(Long id) {
		this.id = id;
	}

	public MessageType getType() {
		return type;
	}

	public void setType(MessageType type) {
		this.type = type;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public Boolean getIsHandled() {
		return isHandled;
	}

	public void setIsHandled(Boolean isHandled) {
		this.isHandled = isHandled;
	}

	@PrePersist
	protected void onCreate() {
		created = new Date();
	}
}
